package vn.demand.dragon.controller
{
	import com.salesbuilder.control.TabManager;
	
	import mx.core.Container;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	import vn.demand.dragon.view.QuotationFormMediator;
	import vn.demand.dragon.view.QuotationLineFormMediator;
	import vn.demand.dragon.view.QuotationPanelMediator;
	
	public class CloseQuotationPanelCommand extends SimpleCommand
	{
		override public function execute( note:INotification ) :void    
		{
			RIALogger.debug(this, "CloseQuotationPanelCommand::execute");
			var quotationVO:Object = note.getBody();
			var panelId:String = QuotationPanelMediator.makeId(quotationVO);
			var m:QuotationPanelMediator = facade.retrieveMediator(panelId) as QuotationPanelMediator;
			var tab:Container = m.panel as Container;
			if (tab == null) return;
			var formId:String = QuotationFormMediator.makeId(quotationVO);
			var lineId:String = QuotationLineFormMediator.makeId(quotationVO);
			facade.removeMediator(panelId);
			facade.removeMediator(formId);
			facade.removeMediator(lineId);
			facade.removeProxy(formId);
			facade.removeProxy(lineId);
			TabManager.removeTab(tab);
        }
	}
}